<%@page pageEncoding="UTF-8" %>
<html class="no-js fixed-layout">
<head>
    <title>user列表</title>
    <%@ include file="/WEB-INF/jsp/include/staticResource.jsp"%>
    <%@ include file="/WEB-INF/jsp/include/meau_head.jsp"%>

</head>
<body>

<!-- content start -->
<div class="admin-content">
    <div class="admin-content-body">
        <div class="am-cf am-padding am-padding-bottom-0">
            <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">表格</strong> / <small>Table</small></div>
        </div>

        <hr>

        <div class="am-g">
            <div class="am-u-sm-12 am-u-md-6">
                <div class="am-btn-toolbar">
                    <div class="am-btn-group am-btn-group-xs">
                        <button type="button" class="am-btn am-btn-default"><span class="am-icon-plus"></span> 新增</button>
                        <button type="button" class="am-btn am-btn-default"><span class="am-icon-save"></span> 保存</button>
                        <button type="button" class="am-btn am-btn-default"><span class="am-icon-archive"></span> 审核</button>
                        <button type="button" class="am-btn am-btn-default"><span class="am-icon-trash-o"></span> 删除</button>
                    </div>
                </div>
            </div>
            <%--<div class="am-u-sm-12 am-u-md-3">
                <div class="am-form-group">
                    <select data-am-selected="{btnSize: 'sm'}">
                        <option value="option1">所有类别</option>
                        <option value="option2">IT业界</option>
                        <option value="option3">数码产品</option>
                        <option value="option3">笔记本电脑</option>
                        <option value="option3">平板电脑</option>
                        <option value="option3">只能手机</option>
                        <option value="option3">超极本</option>
                    </select>
                </div>
            </div>--%>
            <div class="am-u-sm-12 am-u-md-3">
                <div class="am-input-group am-input-group-sm">
                    <input id="userName" name="userName" type="text" class="am-form-field">
                    <span class="am-input-group-btn">
            <button class="am-btn am-btn-default" id="searchUser" onclick="searchUser()" type="button">搜索</button>
          </span>
                </div>
            </div>
        </div>

        <div class="am-g">
            <div class="am-u-sm-12">
                <form class="am-form">
                    <table class="am-table am-table-striped am-table-hover table-main">
                        <thead>
                        <tr>
                            <th class="table-check">
                                <input type="checkbox" />
                            </th>
                            <th class="table-id">用户名</th>
                            <th class="table-title">性别</th>
                            <th class="table-type">手机号码</th>
                            <th class="table-author am-hide-sm-only">QQ</th>
                            <th class="table-date am-hide-sm-only">邮箱</th>
                            <th class="table-date am-hide-sm-only">地址</th>
                            <th class="table-set">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>



                    <hr />
                    <p>注：.....</p>
                    <div id="Pagination" class="pagination"><!-- 这里显示分页 --></div>
                </form>
            </div>
            <input id="pageNo" name="pageNo" type="hidden" value="" />
        </div>
    </div>

    <%--<footer class="admin-content-footer">
        <hr>
        <p class="am-padding-left">© 2014 AllMobilize, Inc. Licensed under MIT license.</p>
    </footer>--%>

</div>
<!-- content end -->
<script type="text/javascript">
  $(function () {
    queryPageUser(0);
  });

  var jsonObj = {
    "pageno" : 1,
    "pagesize" : 20
  };

  function queryPageUser(pageIndex){
    jsonObj.pageno = pageIndex + 1 ;
    $.ajax({
      type : "POST",
      data : jsonObj,
      url : "${APP_PATH}/sysUser/showUserList",
      success : function(result){
        if(result.status=="1"){
          var page = result.page ;
          var data = page.data ;
          var pageNo = page.pageno ;
          $("#pageNo").val(pageNo);
          var content = '';
          $.each(data,function(i,n){
            content+='<tr>';
            content+='  <td><input type="checkbox" id="'+n.id+'" name="'+n.userName+'"></td>';
            content+='  <td>'+n.userName+'</td>';
            content+='  <td>'+n.sex+'</td>';
            content+='  <td>'+n.userPhone+'</td>';
            content+='  <td>'+n.qqNum+'</td>';
            content+='  <td>'+n.userEmail+'</td>';
            content+='  <td>'+n.address+'</td>';

            content+='  <td>';

            content+='      <div class="am-btn-toolbar">';
            content+='          <div class="am-btn-group am-btn-group-xs">';/*onclick="deleteUser('+n.id+',\''+n.loginacct+'\')"*/
            content+='              <button onclick="deleteUser('+n.id+')"  class="am-btn am-btn-default  am-text-secondary"><span class="am-icon-pencil-square-o"></span> 编辑</button>';
            content+='              <button class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only"><span class="am-icon-trash-o"></span> 删除</button>';
            content+='          </div>';
            content+='      </div>';
            content+='  </td>';
            content+='</tr>';
          });
          $("tbody").html(content);
          // 创建分页
          $("#Pagination").pagination(page.totalsize, {
            num_edge_entries: 1, //边缘页数
            num_display_entries: 2, //主体页数
            callback: queryPageUser,
            items_per_page:20, //每页显示1项
            current_page:(page.pageno-1),
            prev_text : "上一页",
            next_text : "下一页"
          });


        }
      },
      error : function(){
        alert("fail");
      }
    });
  }

  function searchUser(){
    var pageNo = $("#pageNo").val();
    var queryText = $("#userName").val();
    jsonObj.queryText = queryText ;
    queryPageUser(parseInt(pageNo)-1);
  }

  function deleteUser(id){
    alert("21321");
    parent.location.href='${APP_PATH}/sysUser/message?id='+id;
  }

</script>


</body>
</html>
